/*
 * 文件名：BaseFragment.java
 * 版权：Copyright 2006-2015 chinasoft Tech. Co. Ltd. All Rights Reserved. 
 * 描述： 功能简述
 * 修改人：Administrator
 * 修改时间：2015年1月4日
 * 修改内容：新增
 */
package com.app.netease.ui.fragment;

import com.app.netease.common.LogUtil;
import com.app.netease.common.StringUtils;
import com.app.netease.http.HttpUtil;
import com.app.netease.http.Url;
import com.app.netease.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

/**
 * <一句话功能简述> <功能详细描述>
 * 
 * @author Administrator [A001]
 * @version 2015年1月4日
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class BaseFragment extends Fragment {

    private static String TAG = BaseFragment.class.getSimpleName();

    public Context ctx;

    @Override
    public void onAttach(Activity activity) {
	super.onAttach(activity);
	LogUtil.i(TAG, "onAttach called...");

	this.ctx = getActivity();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
	LogUtil.i(TAG, "onCreate called...");
	super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
	    Bundle savedInstanceState) {
	LogUtil.i(TAG, "onCreateView called...");
	View rootView = inflater.inflate(R.layout.fragment_main, container,
		false);
	return rootView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);
	LogUtil.i(TAG, "onActivityCreated called...");
    }

    @Override
    public void onStart() {
	LogUtil.i(TAG, "onStart called...");
	super.onStart();
    }

    @Override
    public void onResume() {
	LogUtil.i(TAG, "onResume called...");
	super.onResume();
    }

    @Override
    public void onPause() {
	LogUtil.i(TAG, "onPause called...");
	super.onPause();
    }

    @Override
    public void onStop() {
	LogUtil.i(TAG, "onStop called...");
	super.onStop();
    }

    @Override
    public void onDestroyView() {
	LogUtil.i(TAG, "onDestroyView called...");
	super.onDestroyView();
    }

    @Override
    public void onDestroy() {
	LogUtil.i(TAG, "onDestroy called...");
	super.onDestroy();
    }

    @Override
    public void onDetach() {
	LogUtil.i(TAG, "onDetach called...");
	super.onDetach();
    }
    
    
    protected String contentUrl =  "";
    protected String contentValue = "";
    
    public void setUrlandValueType(int mContentType){
	switch (mContentType) {
	case 0://新闻头条
	    contentUrl =  Url.TopUrl;
	    contentValue = Url.TopId;
	    break;
	case 1://足球
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.FootId;
	    break;
	case 2://娱乐
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.YuLeId;
	    break;
	case 3://体育
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.TiYuId;
	    break;
	case 4://财经
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.CaiJingId;
	    break;
	case 5://科技
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.KeJiId;
	    break;
	case 6://电影
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.DianYingId;
	    break;
	case 7://NBA
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.NBAId;
	    break;
	case 8://数码
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.ShuMaId;
	    break;
	case 9://移动
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.YiDongId;
	    break;
	case 10://彩票
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.CaiPiaoId;
	    break;
	case 11://教育
	    contentUrl =  Url.CommonUrl;
	    contentValue = Url.JiaoYuId;
	    break;
	}
    }
    
    public String getDataUrl(String index){
	String urlString = "";
	urlString = contentUrl + contentValue + "/" + index + Url.endUrl;
	
//	switch (mContentType) {
//	case 0://新闻头条
//	    urlString = Url.TopUrl + Url.TopId + "/" + index + Url.endUrl;
//	    break;
//	case 1://足球
//	    urlString = Url.CommonUrl + Url.FootId + "/" + index + Url.endUrl;
//	    break;
//	case 2://娱乐
//	    urlString = Url.CommonUrl + Url.YuLeId + "/" + index + Url.endUrl;
//	    break;
//	case 3://体育
//	    urlString = Url.CommonUrl + Url.TiYuId + "/" + index + Url.endUrl;
//	    break;
//	case 4://财经
//	    urlString = Url.CommonUrl + Url.CaiJingId + "/" + index + Url.endUrl;
//	    break;
//	case 5://科技
//	    urlString = Url.CommonUrl + Url.KeJiId + "/" + index + Url.endUrl;
//	    break;
//	case 6://电影
//	    urlString = Url.CommonUrl + Url.DianYingId + "/" + index + Url.endUrl;
//	    break;
//	case 7://NBA
//	    urlString = Url.CommonUrl + Url.NBAId + "/" + index + Url.endUrl;
//	    break;
//	case 8://数码
//	    urlString = Url.CommonUrl + Url.ShuMaId + "/" + index + Url.endUrl;
//	    break;
//	case 9://移动
//	    urlString = Url.CommonUrl + Url.YiDongId + "/" + index + Url.endUrl;
//	    break;
//	case 10://彩票
//	    urlString = Url.CommonUrl + Url.CaiPiaoId + "/" + index + Url.endUrl;
//	    break;
//	case 11://教育
//	    urlString = Url.CommonUrl + Url.JiaoYuId + "/" + index + Url.endUrl;
//	    break;
//
//	default:
//	    urlString = Url.TopUrl + Url.TopId + "/" + index + Url.endUrl;
//	    break;
//	}
	
	return urlString;
    }
    
    public String getNewUrl(String index) {
        String urlString = Url.TopUrl + Url.TopId + "/" + index + Url.endUrl;
        return urlString;
    }

    public String getCommonUrl(String index, String itemId) {
        String urlString = Url.CommonUrl + itemId + "/" + index + Url.endUrl;
        return urlString;
    }

    public String getLocalUrl(String index, String itemId) {
        String urlString = Url.Local + itemId + "/" + index + Url.endUrl;
        return urlString;
    }

    public String getFangUrl(String index, String itemId) {
        String urlString = Url.FangChan + itemId + "/" + index + Url.endUrl;
        return urlString;
    }

    public String getPhotosUrl(String index) {
        String urlString = Url.TuJi + index + Url.TuJiEnd;
        return urlString;
    }

    public String getReDianPicsUrl(String index) {
        String urlString = Url.TuPianReDian + index + Url.TuJiEnd;
        return urlString;
    }

    public String getDuJiaPicsUrl(String index) {
        String urlString = Url.TuPianDuJia + index + Url.TuJiEnd;
        return urlString;
    }

    public String getMingXingPicsUrl(String index) {
        String urlString = Url.TuPianMingXing + index + Url.TuJiEnd;
        return urlString;
    }

    public String getTiTanPicsUrl(String index) {
        String urlString = Url.TuPianTiTan + index + Url.TuJiEnd;
        return urlString;
    }

    public String getMeiTuPicsUrl(String index) {
        String urlString = Url.TuPianMeiTu + index + Url.TuJiEnd;
        return urlString;
    }

    public String getSinaJingXuan(String index) {
        String urlString = Url.JINGXUAN_ID + index;
        return urlString;
    }

    public String getSinaQuTu(String index) {
        String urlString = Url.QUTU_ID + index;
        return urlString;
    }

    public String getSinaMeiTu(String index) {
        String urlString = Url.MEITU_ID + index;
        return urlString;
    }

    public String getSinaGuShi(String index) {
        String urlString = Url.GUSHI_ID + index;
        return urlString;
    }

    // ��Ƶ http://c.3g.163.com/nc/video/list/V9LG4B3A0/n/10-10.html
    public String getVideoUrl(String index, String videoId) {
        String urlString = Url.Video + videoId + Url.VideoCenter + index + Url.videoEndUrl;
        return urlString;
    }

    public boolean isNullString(String imgUrl) {

        if (StringUtils.isEmpty(imgUrl)) {
            return true;
        }
        return false;
    }
    
    /**
     * 判断是否有网络
     * 
     * @return
     */
    public boolean hasNetWork() {
        return HttpUtil.isNetworkAvailable(ctx);
    }

    /**
     * 显示LongToast
     */
    public void showShortToast(String pMsg) {
        // ToastUtil.createCustomToast(this, pMsg, Toast.LENGTH_LONG).show();
        Toast.makeText(ctx, pMsg, Toast.LENGTH_SHORT).show();
    }
    
}
